package org.ch00.test07.demo02;

import java.util.Random;

/**
 * 小偷
 *
 * @author ZQX
 * @date 2025-03-05
 */
public class XiaoTou {

    /**
     * 偷盗 - 基于抽象类（父类）实现多态
     *
     * @param door
     */
    public void touDao(Door door) {
        System.out.println("偷你家来了！");
        door.open();

        if (door instanceof IFangDao) {
            IFangDao iFangDao = (IFangDao) door;
            iFangDao.xiangLing();
        }

        int rand = new Random().nextInt(10);

        if (rand >= 5) {
            System.out.println("偷盗成功");
            return;
        }

        System.out.println("偷盗失败");
    }

}
